package com.mhc.suzuki.manager.impl;

import com.mhc.suzuki.dal.mapper.ext.SnapshotExtMapper;
import com.mhc.suzuki.dal.model.SnapshotDO;
import com.mhc.suzuki.dal.query.SnapshotQuery;
import com.mhc.suzuki.manager.SnapshotManager;
import com.subaru.common.query.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


/**
 * Manager for Snapshot.
 */

@Component
public class SnapshotManagerImpl implements SnapshotManager {


    @Autowired
    protected SnapshotExtMapper snapshotExtMapper;

    /**
     * query count by query condition.
     */
    @Override
    public int countByQuery(SnapshotQuery query) {
        return snapshotExtMapper.countByQuery(query);
    }

    /**
     * delete by query condition.
     */
    @Override
    public int deleteByQuery(SnapshotQuery query) {
        return snapshotExtMapper.deleteByQuery(query);
    }

    /**
     * delete by primary key.
     */
    @Override
    public int deleteByPrimaryKey(SnapshotDO record) {
        return snapshotExtMapper.deleteByPrimaryKey(record);
    }

    /**
     * insert selective.
     */
    @Override
    public long insertSelective(SnapshotDO record) {
        return snapshotExtMapper.insertSelective(record);
    }

    /**
     * select by query condition.
     */
    @Override
    public List<SnapshotDO> selectByQuery(SnapshotQuery query) {
        return snapshotExtMapper.selectByQuery(query);
    }

    /**
     * select by query condition with page.
     */
    @Override
    public PageResult<SnapshotDO> selectByQueryWithPage(SnapshotQuery query) {
        PageResult<SnapshotDO> result = new PageResult<SnapshotDO>();
        result.setPageSize(query.getPageSize());
        result.setPageNo(query.getPageNo());
        result.setTotalCount(this.countByQuery(query));
        result.setResult(this.selectByQuery(query));
        return result;
    }

    /**
     * select by primary key.
     */
    @Override
    public SnapshotDO selectByPrimaryKey(Long id) {
        return snapshotExtMapper.selectByPrimaryKey(id);
    }

    /**
     * update by query condition selective.
     */
    @Override
    public int updateByQuerySelective(SnapshotDO record, SnapshotQuery query) {
        return snapshotExtMapper.updateByQuerySelective(record, query);
    }

    /**
     * update by query condition.
     */
    @Override
    public int updateByQuery(SnapshotDO record, SnapshotQuery query) {

        return snapshotExtMapper.updateByQuery(record, query);
    }

    /**
     * update by primary key selective.
     */
    @Override
    public int updateByPrimaryKeySelective(SnapshotDO record) {
        return snapshotExtMapper.updateByPrimaryKeySelective(record);
    }
}